package com.kaibes.web.status;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PostMapping;

import com.kaibes.web.filter.FilterInternalConfig;

@Configuration
public class StatusConfig {
    
    @Autowired
    private FilterInternalConfig config;
    
    @PostMapping
    public void init() {
    	config.getPathWhiteStartList().add("/error");
    }

    private Map<Integer, String> statusViewMap = new HashMap<>();
    {
//        statusViewMap.put(HttpServletResponse.SC_UNAUTHORIZED, "/error/401.html");
//        statusViewMap.put(HttpServletResponse.SC_FORBIDDEN, "/error/403.html");
//        statusViewMap.put(HttpServletResponse.SC_NOT_FOUND, "/error/404.html");
//        statusViewMap.put(HttpServletResponse.SC_REQUEST_TIMEOUT, "/error/408.html");
//        statusViewMap.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "/error/500.html");
    }
    
    public StatusConfig putStatusView(Integer key, String path) {
        statusViewMap.put(key, path);
        return this;
    }

    public Map<Integer, String> getStatusViewMap() {
        return statusViewMap;
    }
    
}
